<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="com.sms.project.*" %>

<%--
	project/teacher/project.jsp
 --%>

<%	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0); 
%>

<%
	String progress = request.getParameter("progress");
	//System.out.println("progress1" + progress);
	String select[] = new String[3];
	if(progress != null) {
		if(progress.trim().equals("already")) {
			select[0] = "selected";
		} else if(progress.trim().equals("unalready")){
			select[1] = "selected";
		} else {
			select[2] = "selected";
		}
	} else {
			select[2] = "selected";
	}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<div class="button">
<a class="easyui-linkbutton" id="add"  iconCls="icon-add">添加项目</a><a class="easyui-linkbutton" id='cut'  iconCls="icon-cut">批量删除项目</a>
<!--  <a class="easyui-linkbutton" id="select-all" iconCls="icon-edit">全选</a> -->
项目进度：<select style="width:80px;">
	<option value="all" <%= select[2] %>>全部</option>
	<option value="already" <%= select[0] %>>已完成</option>
	<option value="unalready" <%= select[1] %>>未完成</option>
</select>
<input type="submit"  id='pro-search'  value="搜索" />
</div>
<form id="all-project">
<input type="hidden" name="action" value="delete"/>
<table class="project" cellpadding="0" cellspacing="0">
</table>
</form>
<div id="dd"></div>

<script type="text/javascript">
$.ajaxSetup({
	dataType:'html',
	cache:false
	})
	/*详细信息处理*/	 
$('.project').datagrid({
 	url:'project/teacher/query-project.jsp?progress=' + $('select option:selected').attr('value'), //返回数据的链接
	idField:'code',
	pagination:true,
	columns:[[
			{field:'cut',checkbox:true },
			{field:'code',title:'项目编号',width:70},
			{field:'name',title:'项目名称',width:220},
			{field:'status',title:'项目进度',width:100},
			{field:'grade',title:'项目级别',width:100},
			{field:'prodetail',title:'详细信息',width:100},
			{field:'repdetail',title:'任务/信息交流',width:100},
			{field:'change',title:'更改进度',width:80},   //里面显示    更改
		]],
	onDblClickCell:function(rowIndex, field, value){
		$(this).click(function(){
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		})
		if(field=='prodetail'){
			 $('#dd').dialog({
		         title:"项目详情",
				 zIndex:9001,
				 width:800, height:600,
				 top:40,left:300,
				 cache:false,
				 resizable:true,
				href:'project/teacher/item-details.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value')//！！！！后台请注意获取的时候检测一下
		   });
		  $('#dd').dialog('refresh', 'project/teacher/item-details.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value'));
			}
		else if(field=='protest'){
			 $('#dd').dialog({
		         title:"查看已发布任务",
				 zIndex:9001,
				 width:820, height:490,
				 top:140,left:365,
				 cache:false,
				 resizable:true,
				href:'project/teacher/manage-task.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value') //！！！！后台请注意获取的时候检测一下如果是两级还是三级
				//href:'project/teacher/add-task.jsp?row='+rowIndex //！！！！后台请注意获取的时候检测一下如果是两级还是三级
		   });
		   $('#dd').dialog('refresh', 'project/teacher/manage-task.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value'));
		   }
		   else if(field=='repdetail'){
			    $('#dd').dialog({
		         title:"任务/信息交流",
				 zIndex:9001,
				width:1000, height:600,
				 top:40,left:200,
				 maximizable:true,
				 cache:false,
				 resizable:true,
				href:'project/teacher/report-detail.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value') 
		   });
		     $('#dd').dialog('refresh', 'project/teacher/report-detail.jsp?row='+rowIndex + '&progress=' + $('select option:selected').attr('value') );
			   }
			   else if(field=='change'){
			     if(confirm('确定要更改项目进度吗？')){
					$.ajax({
						 url:'project/teacher/change-progress.jsp',//项目进度更改处理链接，
						  data:'row='+rowIndex + '&progress=' + $('select option:selected').attr('value'),
						  dataType:'text',
						 success:function(msg){ 
						 	//alert(msg);  
							  if(msg=='ok'){
								  alert('修改成功');
						 var tab = $(".easyui-tabs").tabs('getSelected');
			 		    $(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'project/teacher/project.jsp?progress=' + $('select option:selected').attr('value'),
									 }
									}
									
									);  /*更新面板*/
								  }
							else {
								alert("修改失败");
								//alert(msg);
							}
							  }
						 })
						
				
					 }
			   }
		
		},
	

})
 var selectRow=$('.project').datagrid('getRowIndex');
/*添加处理*/
 $("#add").click(function(){
			$('#dd').dialog({
			         title:"添加项目",
					  zIndex:9001,
					 width:800, height:550,
					 top:40,left:300,
					 cache:false,
					 resizable:true,
					 href:'project/teacher/add-project.jsp' 
					 });
			 $('#dd').dialog('refresh', 'project/teacher/add-project.jsp' );	
		
})
/*全选*/
$('#select-all').click(function(){
	$('.project').datagrid('selectAll');
	})
/*删除处理*/
$("#cut").click(function(){
       var ids=[];
        var rows = $('.project').datagrid('getSelections'); 
		if (!rows || rows.length == 0) {
         $.messager.alert('提示', '请选择要删除的数据!', 'info');return;}  
      $.each(rows, function (i, n) {
     ids.push(n.code);
});
$.messager.confirm('提示', '是否删除选中数据?', function (r) {
if (!r) {
return;
} 
//alert(ids);
$.ajax({
		   url:'project/teacher/del-project.jsp',       /*删除处理界面,传到后台的是所有选中的行号组成的数字数组*/
		   data:'selectrows='+ids,
		   dataType:'text',
		   success:function(msg){
			   if(msg=='ok'){
				   alert("删除成功");
			 	  	var tab = $(".easyui-tabs").tabs('getSelected');;
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'project/teacher/project.jsp?progress=' + $('select option:selected').attr('value'),
									 }
									}
									);  /*更新面板*/

				   } 
          		else{
					alert("删除失败");
					}
				}
			  
		   })
})
		  })
	
/*搜索处理*/
$("#pro-search").click(function(){
	var tab = $(".easyui-tabs").tabs('getSelected');;
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									options:{
								      cache:false,
                                      href:'project/teacher/project.jsp?progress=' + $('select option:selected').attr('value')}
									}
									);  /*更新面板*/	
		
	})
</script>
</body>

